package cn.sgjk.train.business.controller.admin;


import cn.sgjk.train.business.service.TrainSeatService;
import cn.sgjk.train.common.context.LoginMemberContext;
import cn.sgjk.train.common.resp.CommonResp;
import cn.sgjk.train.common.resp.PageResp;
import cn.sgjk.train.business.req.StationQueryReq;
import cn.sgjk.train.business.req.StationSaveReq;
import cn.sgjk.train.business.resp.StationQueryResp;
import cn.sgjk.train.business.service.StationService;
import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/station")
public class StationAdminController {

    private static final Logger LOG = LoggerFactory.getLogger(StationAdminController.class);
    @Autowired
    private StationService stationService;





    @PostMapping("/save")
    public CommonResp<Object> save(@Valid @RequestBody StationSaveReq stationReq) {
        stationService.save(stationReq);
        return new CommonResp<>();
    }



    @GetMapping("/query-list")
    public CommonResp<PageResp<StationQueryResp>> query(@Valid StationQueryReq stationQueryReq) {
        PageResp<StationQueryResp> stationQueryResps = stationService.queryList(stationQueryReq);
        return new CommonResp<>(stationQueryResps);
    }

    @DeleteMapping("/delete/{id}")
    public CommonResp<Object> delete(@PathVariable Long id) {
        stationService.delete(id);
        return new CommonResp<>();
    }

    @GetMapping("/query-all")
    public CommonResp<List<StationQueryResp>> queryAll() {
        List<StationQueryResp> stationResps = stationService.queryAll();
        return new CommonResp<>(stationResps);
    }



}

